home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / mawk.zip / MACHINE.H < prev    next >
C/C++ Source or Header  |  1991-04-09  |  4KB  |  161 lines

  1.  
  2. /********************************************
  3. machine.h
  4. copyright 1991, Michael D. Brennan
  5.  
  6. This is a source file for mawk, an implementation of
  7. the Awk programming language as defined in
  8. Aho, Kernighan and Weinberger, The AWK Programming Language,
  9. Addison-Wesley, 1988.
  10.  
  11. See the accompaning file, LIMITATIONS, for restrictions
  12. regarding modification and redistribution of this
  13. program in source or binary form.
  14. ********************************************/
  15.  
  16. /*$Log:    machine.h,v $
  17.  * Revision 2.2  91/04/09  12:39:14  brennan
  18.  * added static to funct decls to satisfy STARDENT compiler
  19.  * 
  20.  * Revision 2.1  91/04/08  08:23:25  brennan
  21.  * VERSION 0.97
  22.  * 
  23. */
  24.  
  25.  
  26. /* I've attempted to isolate machine/system dependencies here.
  27.  
  28.    Floating point exceptions are the biggest hassle.
  29.    If you have IEEE754 floating point, turn off floating point
  30.    traps and let the INFs and NANs go berserk.  This should be
  31.    the default (see page 14 of IEEE754), but ANSI C seems to imply
  32.    they should be on (i.e., one standards committee does not talk to
  33.    the other).  Anyway, define a macro TURNOFF_FPE_TRAPS() which will
  34.    probably be a 1 liner.
  35.  
  36.    If you cannot turn off floating exceptions, check out
  37.    fpe_catch() in matherr.c and modify as needed for your machine.
  38.    Also you may need to define FPE_ZERODIVIDE and FPE_OVERFLOW.
  39.  
  40.    If you have SysV like matherr(), use it.
  41.    If you have SysV compatible math lib , use it.
  42.    You might need to supply a macro to replace drand48(), otherwise.
  43.    (See BSD43 for no IEEE754, no matherr(), no fmod(),
  44.     no strtod(), no drand48())
  45.  
  46.    If you have to be conservative with memory (e.g., small model
  47.    MsDos), a small evaluation stack (16-32) is plenty.
  48.    Recursive functions calls are the only reason you need a big
  49.    stack.  The default for MsDos uses 64 which allows some
  50.    recursion without killing too many memory CELLs.
  51. */
  52.  
  53. /*  MsDOS --
  54.     If you use command.com as the shell, entering programs on the
  55.     command line is hopeless.  Command.com will always glom onto
  56.     | or < or > as redirection.
  57.  
  58.     If you use a Unix style shell under DOS, then you need to
  59.     write 
  60.  
  61.         void  reargv(int *argc, char ***argv)
  62.  
  63.     which gets the arguments from your shell, and then
  64.  
  65.     #define   HAVE_REARGV    1
  66.  
  67.     See README in dos directory
  68.     and MsDos section of manual.
  69. */
  70.  
  71. #ifndef    MACHINE_H
  72. #define    MACHINE_H
  73.  
  74.  
  75. #ifdef  sun   /* sun3 or sun4 with SUNOS 4.0.3 */
  76. #define  FPE_TRAPS              0
  77. #define  TURNOFF_FPE_TRAPS()    /* empty, default is off */      
  78. #define  HAVE_MATHERR           1
  79. #endif
  80.  
  81. #ifdef    __TURBOC__
  82. #define   DOS            1
  83. #define   SMALL_EVAL_STACK      1
  84. #define  FPE_TRAPS              0
  85. #define  TURNOFF_FPE_TRAPS()    _control87(0x3f,0x3f)
  86. #define  HAVE_MATHERR           1
  87. #endif
  88.  
  89. #ifdef   ULTRIX  /* V4.1 on a vax 3600 */
  90. #define  HAVE_VOID_PTR          1
  91. #define  HAVE_MATHERR           1
  92. #define   FPE_ZERODIVIDE   FPE_FLTDIV_FAULT
  93. #define   FPE_OVERFLOW     FPE_FLTOVF_FAULT
  94. #endif
  95.  
  96. #ifdef    BSD43   /* on a vax */
  97. #define   NO_STRTOD             1
  98. #define   NO_FMOD               1
  99. #define   srand48(x)    srandom(x)
  100. #define   drand48() (((double)random())/((double)(unsigned)0x80000000))
  101. #define   vfprintf(s,f,a)  _doprnt(f,a,s)
  102. #define   FPE_ZERODIVIDE   FPE_FLTDIV_FAULT
  103. #define   FPE_OVERFLOW     FPE_FLTOVF_FAULT
  104. #endif
  105.  
  106. #ifdef   STARDENT  /* Stardent 3000, SysV R3.0 */
  107. #define  HAVE_MATHERR    1
  108. #define  FPE_TRAPS    0
  109. #define  TURNOFF_FPE_TRAPS()    /* nothing */
  110. #define  HAVE_VOID_PTR    1
  111. #endif
  112.  
  113. /*  the defaults    */
  114. #ifndef   HAVE_VOID_PTR
  115. #define   HAVE_VOID_PTR         0  /* no void * */
  116. #endif
  117.  
  118. #ifndef   FPE_TRAPS
  119. #define   FPE_TRAPS             1  
  120.     /* floating point errors generate exceptions  */
  121. #endif
  122.  
  123. #ifndef   HAVE_MATHERR
  124. #define   HAVE_MATHERR          0
  125.     /*  SysV style matherr() is not available */
  126. #endif
  127.  
  128. #ifndef  NO_STRTOD
  129. #define  NO_STRTOD              0 /* default is have */
  130. #endif
  131.  
  132. #ifndef  SMALL_EVAL_STACK
  133. #define  SMALL_EVAL_STACK       0
  134. #endif
  135.  
  136. #ifndef  NO_FMOD
  137. #define  NO_FMOD                0 /* default is to have fmod() */
  138. #endif
  139.  
  140. #define   STDC_MATHERR          (FPE_TRAPS && ! HAVE_MATHERR)
  141.  
  142. #ifndef   DOS
  143. #define   DOS    0
  144. #endif
  145.  
  146. #if   DOS 
  147.  
  148. #ifndef  HAVE_REARGV
  149. #define  HAVE_REARGV    0
  150. #endif
  151.  
  152. #define  DOS_PROMPT     "mawk> "
  153.     /* change to "mawk \01 "  on a good day */
  154. #endif
  155.  
  156.  
  157.  
  158.  
  159.  
  160. #endif   /* MACHINE_H  */
  161.